<% content_for :title do %>Bestellingen<% end %>
<%form_tag(admin_orders_path, :method => :get) do %>
<table width=100px>
	<tr>
		<td>gebruikersnaam:</td>
		<td>bestellingscode:</td>
		<td>besteld vanaf:</td>
	</tr>
	<tr>
		<td width="10%"><%= text_field_tag :user, @user%></td>
		<td width="10%"><%= text_field_tag :order_id, @order_id%></td>
		<td width="20%"><%= select_date @date_from, :prefix => :from, :start_year => 2000, :end_year => Time.now.year, :include_blank => true%></td>
	</tr>
	<tr>
		<td>email adres:</td>
		<td>betaal methode:</td>
		<td>besteld tot:</td>
	</tr>
	<tr>
		<td width="10%"><%= text_field_tag :email, @email%></td>
		<td width="10%"><%= select_tag :payment_type, options_for_select([[],['Creditcard','1'],['Op rekening','2']],@payment_type)%></td>		
		<td width="20%"><%= select_date @date_to, :prefix => :to, :start_year => 2000, :end_year => Time.now.year, :include_blank => true%></td>
	</tr>
	<tr>
		<td>status:</td>
	</tr>
	<tr>
		<td width="10%"><%= get_status(1)%><%= check_box_tag :status_one, '1', @status_one%></td>
		<td width="10%"><%= get_status(2)%><%= check_box_tag :status_two, '2', @status_two%></td>
		<td width="10%"><%= get_status(3)%><%= check_box_tag :status_three, '3', @status_three%></td>
		
	</tr>
	<tr>
		<td width="10%"><%= get_status(4)%><%= check_box_tag :status_four, '4', @status_four%></td>
		<td width="10%"><%= get_status(5)%><%= check_box_tag :status_five, '5', @status_five%></td>
		<td width="10%"><%= submit_tag 'Zoek'%></td>
	</tr>
</table>
<%end%>
<table width="60%">
	<%if(@orders.size)>0%>
	<tr>
		<%sort = @params[:sort]%>
		<%sort_on = @params[:sort_on]%>
		<th align="left">Bestellingscode:<%= link_to image_tag("asc.gif"), admin_orders_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'orders.id')%><%= link_to image_tag("desc.gif"), admin_orders_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'orders.id')%></td>
		<th align="left">Gebruikersnaam:<%= link_to image_tag("asc.gif"), admin_orders_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'users.name')%><%= link_to image_tag("desc.gif"), admin_orders_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'users.name')%></td>
		<th align="left">Geplaatst:<%= link_to image_tag("asc.gif"), admin_orders_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'orders.created_at')%><%= link_to image_tag("desc.gif"), admin_orders_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'orders.created_at')%></td>
		<th align="left">Status:<%= link_to image_tag("asc.gif"), admin_orders_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'orders.status')%><%= link_to image_tag("desc.gif"), admin_orders_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'orders.status')%></td>
		<th align="left">Betaaltype:<%= link_to image_tag("asc.gif"), admin_orders_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'orders.payment_type')%><%= link_to image_tag("desc.gif"), admin_orders_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'orders.payment_type')%></td>
		<%@params[:sort] = sort%>
		<%@params[:sort_on] = sort_on%>
	</tr>
	<%end%>
	<% @orders.each do |order|%>
		<%= render :partial => 'order_admin', :locals => {:order => order}%>
	<%end%>
</table>
<p>
<% if @indices[0] > -1 then%>
	<%= link_to 'vorige', admin_orders_path(@params, @params[:page] = @indices[0])%>
<%end%>
<% if @indices[1] != nil then%>
	<%= link_to 'volgende', admin_orders_path(@params, @params[:page] = @indices[1])%>
<%end%>
</p>